<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model='value'>
        <p>姓:{{xing}}</p>
        <p>名:{{ming}}</p>
    </div>
    <script src="../vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data () {
                return {
                    value:'',
                    ary:[
                        '欧阳',
                        '司马',
                        '司徒',
                        '诸葛'
                    ],
                }
            },
            computed: {
                xing(){
                    if(this.value.length>2){
                        if(this.ary.includes(this.value.substr(0,2))){
                            return this.value.substr(0,2);
                        }
                        else{
                            return this.value.substr(0,1);
                        }
                    }
                    else{
                        return this.value.substr(0,1);
                    }
                },
                ming(){
                    if(this.value.length>2){
                        if(this.ary.includes(this.value.substr(0,2))){
                            return this.value.substr(2);
                        }
                        else{
                            return this.value.substr(1);
                        }
                    }
                    else{
                        return this.value.substr(1);
                    }
                }
            }
        })
    </script>
</body>
</html>